package com.blockmeta.bbs.immodule.corebean.Impl;

import android.content.Context;
import com.blankj.utilcode.util.LogUtils;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.blockmeta.bbs.baselibrary.provider.IMApplicationContextProvider;
import com.blockmeta.bbs.businesslibrary.arouter.RouterPath;
import com.blockmeta.bbs.immodule.corebean.IChatMessageDomainService;
import com.blockmeta.bbs.immodule.corebean.ICircleDomainService;
import com.blockmeta.bbs.immodule.corebean.IDomainCommonManger;
import com.blockmeta.bbs.immodule.corebean.IMDomainFactory;
import com.blockmeta.bbs.immodule.corebean.IMMetaBase;
import com.blockmeta.bbs.immodule.corebean.ITodoDomainService;
import com.blockmeta.bbs.immodule.corebean.IUserDomainService;
import com.blockmeta.bbs.immodule.greendao.repository.IChatMessageRepo;
import com.blockmeta.bbs.immodule.greendao.repository.ITodoRepo;
import com.blockmeta.bbs.immodule.greendao.repository.IUserRepo;

@Route(path = RouterPath.IM_APPLICATIONCONTEXT_PROVIDER)
public class IMApplicationContext implements IMApplicationContextProvider {

    @Override
    public void onCreate(Context context){

        LogUtils.d("authorkkk" + "IMApplicationContext onCreate");
        getIMMetaService().onCreate();
    }

    @Override
    public void onDestroy(Context mContext) {
        getIMMetaService().onStopServer();
    }

    public static IMMetaBase getIMMetaService(){
        return IMDomainFactory.createIMMetaService();
    }

    public static ICircleDomainService getCircleDomainService(){
        return IMDomainFactory.createCircleDomainService();
    }

    public static IChatMessageDomainService getChatMessageDomainService(){
        return IMDomainFactory.createChatMessageDomainService();
    }

    public static IUserDomainService getUserDomainService(){
        return IMDomainFactory.createUserDomainService();
    }


    /**
     * 内部通用业务，不应许controller调用
     * @return
     */
    protected static IDomainCommonManger getDomainCommonManger(){
        return IMDomainFactory.createDomainCommonManger();
    }


    public static ITodoDomainService getTodoDomainService(){
        return IMDomainFactory.createTodoDomainService();
    }
    @Override
    public void init(Context context) {

    }
}
